#include "imageclip.h"

void ImageClip::draw(SDL_Surface * a_dest, const SPoint & a_position, const int & a_transparentColor)
{
//	VSDL_drawSurfaceToSurface(a_dest, a_position, image, &clip, 0, 1);
	if((int)image > 1000)
	{
//		RGB_QUAD magenta(255,0,255,0);
//		int magentaIndex = image->getColorIndex(magenta);
		VSDL_drawBitmapToSurface(a_dest, a_position, image, clip, VSDL_FLIP_NONE, 1, a_transparentColor);
	}
	else
	{
		SRect r(clip);
		r.setPosition(a_position);
		VSDL_drawRect(a_dest, &r, -1, 1);
	}
}

/**
 * @param a_dest which context to draw the clip in
 * @param a_position where in the context to draw the clip
 * @param a_flip what VSDL_FLIP_* flags to set, determining flip
 * @param a_pixelSize the multiplier (zoom) to draw at
 * @param a_transparentColor which index color to not draw
 */
void ImageClip::draw(SDL_Surface * a_dest, const SPoint & a_position, 
					 const int & a_flip, const int & a_pixelSize, const int & a_transparentColor)
{
//	VSDL_drawSurfaceToSurface(a_dest, a_position, image, &clip, a_flip, a_pixelSize);
	if((int)image > 1000)
	{
		// the final flip of this clip, based on it's internal flip and the parameter flip
		// TODO: test. don't think this will work correctly
//		RGB_QUAD magenta(255,0,255,0);
//		int magentaIndex = image->getColorIndex(magenta);
		VSDL_drawBitmapToSurface(a_dest, a_position, image, clip, a_flip, a_pixelSize, a_transparentColor);
	}
	else
	{
		// TODO: test. don't think this will work correctly
		SRect r(clip);
		r.setPosition(a_position);
		r.setWidth(r.getWidth()*a_pixelSize);
		r.setHeight(r.getHeight()*a_pixelSize);
		VSDL_drawRect(a_dest, &r, 0, 1);
	}
}
